﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;


namespace FrbaCommerce.Login
{
    public partial class frm_seleccionarRol : Form
    {
        public frm_seleccionarRol()
        {
            InitializeComponent();
        }

        private void frm_seleccionarRol_Load(object sender, EventArgs e)
        {
            BaseDeDatos baseDeDatos = BaseDeDatos.Instance;
            SqlCommand sqlCommand = new SqlCommand();
            sqlCommand.CommandText = "LOS_GDDES.SP_TRAER_ROLES_X_USUARIO";
            sqlCommand.CommandType = CommandType.StoredProcedure;
            sqlCommand.Parameters.AddWithValue("@id_usuario", baseDeDatos.idUsuario);
            DataTable dt_roles = baseDeDatos.consulta(sqlCommand);
            cmb_roles.DataSource = dt_roles;
            cmb_roles.DisplayMember = "NOMBRE";
            cmb_roles.ValueMember = "ID_ROL";
        }

        private void btn_aceptar_Click(object sender, EventArgs e)
        {
            BaseDeDatos baseDeDatos = BaseDeDatos.Instance;
            baseDeDatos.idRol = Convert.ToInt32(cmb_roles.SelectedValue);
            frm_menu frm_menu = new frm_menu();
            frm_menu.ShowDialog();
            this.Close();
        }

        private void btn_cancelar_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}